//命名路由
import 'package:flutter/material.dart';
import '../form.dart';

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          ElevatedButton(
            onPressed: () {
              Navigator.of(context).push(
                MaterialPageRoute(
                  builder: (context) {
                    return FormPage();
                  },
                ),
              );
            },
            child: Text('基本路由表跳转'),
          ),
          SizedBox(height: 20),
          Divider(),
          ElevatedButton(
            onPressed: () {
              Navigator.pushNamed(context, '/news');
            },
            child: Text('命名路由跳转'),
          ),
          SizedBox(height: 20),
          ElevatedButton(
            onPressed: () {
              Navigator.pushNamed(
                context,
                '/form',
                arguments: {'name': '张三', 'age': 18},
              );
            },
            child: Text('命名路由传值--Form'),
          ),
          SizedBox(height: 20),
          ElevatedButton(
            onPressed: () {
              Navigator.pushNamed(
                context,
                '/shop',
                arguments: {'name': '课本', 'price': 56},
              );
            },
            child: Text('命名路由传值--Shop'),
          ),
        ],
      ),
    );
  }
}
